/**
 * 
 */
package ro.utcn.tp.taskManagement.business;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

/**
 * @author Coni
 * 
 */
public class ImageService {
	/** A instance of image service. */
	private static ImageService instance;

	/**
	 * @return the image service instance.
	 */
	public static ImageService getInstance() {
		if (instance == null) {
			instance = new ImageService();
		}
		return instance;
	}

	/**
	 * The private constructor for this class.
	 */
	private ImageService() {
		// private constructor
	}

	/**
	 * {@inheritDoc}
	 */
	public ImageIcon getIcon(String iconPath) {// returneaza iconul
		ImageIcon icon = new ImageIcon(iconPath);
		return icon;
	}

	/**
	 * {@inheritDoc}
	 */
	public BufferedImage getImage(String imagePath) {// returneaza un buffer
														// image
		BufferedImage image = null;
		File imageFile = new File(imagePath); // creaza new file de pathul ce
												// l-a gasit
		try {
			image = ImageIO.read(imageFile);// citeste imaginea de pe disc si o
											// stocheaza in buffer image
		} catch (IOException e) {
			e.printStackTrace();
		}
		return image;
	}// ca sa afisez imaginea aplicatiei

}
